class Solution:
    def convertToBase7(self, num: int) -> str:
        if not num:
            return '0'
        ans = ""
        if num < 0:
            num = -num
            flag = False
        else:
            flag = True
        while num:
            ans += str(num % 7)
            num //= 7
        return ans[::-1] if flag else '-' + ans[::-1]


if __name__ == '__main__':
    a = Solution()
    print(a.convertToBase7(-7))
    print(a.convertToBase7(70))
